<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<PaginatedList<MembershipUser>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Admin User List
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="AdminContent" runat="server">
    <h2>
        Admin User List
    </h2>
    <h4>
        <%= base.Html.ActionLink("New user", "Create", "AdminUser", null, null) %>
    </h4>
    <table>
        <thead>
            <tr>
                <th rowspan="2">
                </th>
                <th rowspan="2">
                    User Name
                </th>
                <th rowspan="2">
                    Email
                </th>
                <th colspan="4">
                    Dates
                </th>
                <th colspan="4">
                    Status
                </th>
            </tr>
            <tr>
                <th>
                    Created
                </th>
                <th>
                    Last Login
                </th>
                <th>
                    Last Active
                </th>
                <th>
                    Last Lock
                </th>
                <th>
                    Online
                </th>
                <th>
                    Approved
                </th>
                <th>
                    Locked
                </th>
                <th>
                    Delete
                </th>
            </tr>
        </thead>
        <tbody>
            <%
                if ((base.Model != null) && (base.Model.Count > 0))
                {
                    foreach (MembershipUser user in base.Model)
                    {
            %>
            <tr>
                <td>
                    <%= base.Html.ActionLink("Details", "Details", "AdminUser", new { username = user.UserName }, null)%>
                </td>
                <td>
                    <%= user.UserName%>
                </td>
                <td>
                    <%= user.Email%>
                </td>
                <td>
                    <%= user.CreationDate.ToShortDateString()%>
                </td>
                <td>
                    <%= user.LastLoginDate.ToShortDateString()%>
                </td>
                <td>
                    <%= user.LastActivityDate.ToShortDateString()%>
                </td>
                <td>
                    <%= (user.CreationDate > user.LastLockoutDate) ? "" : user.LastLockoutDate.ToShortDateString()%>
                </td>
                <td>
                    <%= base.Html.CheckBox("IsOnline", user.IsOnline, new { disabled = "disabled" })%>
                </td>
                <td>
                    <%= base.Html.CheckBox("IsApproved", user.IsApproved, new { disabled = "disabled" })%>
                </td>
                <td>
                    <%= base.Html.CheckBoxItem("IsLockedOut" + user.UserName, "IsLockedOut", user.IsLockedOut, !user.IsLockedOut, user.UserName)%>
                </td>
                <td>
                    <%= Html.CheckBoxItem("Delete" + user.UserName, "Delete", false, (String.Compare(user.UserName, Page.User.Identity.Name, true) == 0), user.UserName)%>
                </td>
            </tr>
            <% 
                }
                }
                else
                {
            %>
            <tr>
                <td colspan="11">
                    No users present
                </td>
            </tr>
            <%
                }
            %>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="6">
                    <% base.Html.RenderPartial("PaginatedListFooter"); %>
                </td>
                <td colspan="5" class="align_right">
                    <input type="submit" value="Delete" />
                </td>
            </tr>
        </tfoot>
    </table>
</asp:Content>
